package com.bls.service.impl;

import com.bls.action.BLSAction;
import com.bls.dao.ActionLogDao;
import com.bls.dao.DraftDao;
import com.bls.entity.ActionLog;
import com.bls.entity.Draft;
import com.bls.entity.vo.DraftVo;
import com.bls.service.ActionLogService;
import org.springframework.beans.BeanUtils;
import org.springframework.util.StringUtils;

import java.lang.reflect.InvocationTargetException;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

/**
 * (ActionLog)表服务实现类
 *
 * @author makejava
 * @since 2022-01-13 09:58:37
 */
public class ActionLogServiceImpl implements ActionLogService {
    @Override
    public void save(ActionLog actionLog) throws Exception{
        ActionLogDao actionLogDao = BLSAction.getBean(ActionLogDao.class);
        final Connection connection = BLSAction.getDBConnection();

        try {
            actionLogDao.save(connection, actionLog);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    @Override
    public List<ActionLog> pageConditionActionLogList(ActionLog actionLogQuery, Integer pageSize, Integer current) throws Exception {
        ActionLogDao actionLogDao = BLSAction.getBean(ActionLogDao.class);
        final Connection connection = BLSAction.getDBConnection();
        List<ActionLog> actionLogList = null;
        try {
            actionLogList = actionLogDao.pageConditionActionLogList(connection, actionLogQuery, pageSize, current);

        } catch (Exception e) {
            e.printStackTrace();
        }
        return actionLogList;
    }

    @Override
    public Integer pageConditionActionLogListTotal(ActionLog actionLogQuery) throws Exception  {
        ActionLogDao actionLogDao = BLSAction.getBean(ActionLogDao.class);
        final Connection connection = BLSAction.getDBConnection();

        int count = -1;
        try {
            count = actionLogDao.pageConditionActionLogListTotal(connection, actionLogQuery);
        } catch (SQLException e) {
            e.printStackTrace();
        }
        return count;
    }

}
